import axios from './axios.js'

export const login = (params) => {
	return axios.request({
		url: 'api/login',
		method: 'post',
		data: params
	})
}

export const getUserList = (params) => {
	return axios.request({
		 url: 'api/system/user/list',
		 method: 'get',
		 params
	})
}

export function getUser(userId) {
  return axios.request({
    url: 'api/system/user/' + userId,
    method: 'get'
  })
}

export function addUser(data) {
  return axios.request({
    url: 'api/system/user',
    method: 'post',
    data: data
  })
}

export function updateUser(data) {
  return axios.request({
    url: 'api/system/user',
    method: 'put',
    data: data
  })
}

export function delUser(userId) {
  return axios.request({
    url: 'api/system/user/'+userId,
    method: 'delete',
	// data: {id:userId}
  })
}

export function getUserProfile() {
  return axios.request({
    url: 'api/system/user/profile',
    method: 'get'
  })
}

export function updateUserProfile(data) {
  return axios.request({
    url: 'api/system/user/profile',
    method: 'put',
    data: data
  })
}

export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return axios.request({
    url: 'api/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}